package com.itheima.demo05;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author Zhang_Han
 * @version 1.0
 * @date 2020/7/13 19:47
 */
public class Demo_006 {
    public static void main(String[] args) {
        //ExecutorService newFixedThreadPool(int nThreads)  ： 创建线程池对象，并限制最大线程数
        ExecutorService e = Executors.newFixedThreadPool(3);

        e.submit(() -> {
            System.out.println(Thread.currentThread().getName() + "执行了");
        });
        e.submit(() -> {
            System.out.println(Thread.currentThread().getName() + "执行了");
        });
        e.submit(() -> {
            System.out.println(Thread.currentThread().getName() + "执行了");
        });
        e.submit(() -> {
            System.out.println(Thread.currentThread().getName() + "执行了");
        });

        e.shutdown();
    }
}
